<?php
/**
 * @package		Joomla.Site
 * @subpackage	Templates.beez5
 * @copyright	Copyright (C) 2005 - 2009 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
// no direct access
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$templateparams = $app->getTemplate(true)->params;

require JPATH_BASE . '/components/com_content/views/category/tmpl/blog.php';
//evtl. ersetzen durch JPATH_COMPONENT.'/views/...'
// If the page class is defined, add to class as suffix.
// It will be a separate class if the user starts it with a space
$params = & $this->item->params;
require_once(JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php');
//check if products menu
$idcat = JRequest::getVar('id','','get','int');
$db = JFactory::getDbo();
$sql = "SELECT * from #__categories where id = '".$idcat."' and parent_id = 78 and published=1";
$db->setQuery($sql);
$db->query($sql);
$result = $db->getNumRows();
if($result==1) $class = 'cat_mod'; else $class = '';
?>

<ul class="Group_News <?php echo $class;?>">
<?php
JRequest::setVar('limit', JRequest::getVar('limit', 7, '', 'int'));
JRequest::setVar('limitstart', JRequest::getVar('limitstart', 0, '', 'int'));
jimport('joomla.html.pagination');
$catid = JRequest::getInt('id');
$lang =& JFactory::getLanguage();
$langdefault = $lang->getTag();

$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('*');
$query->from('#__content');
$query->where("catid = '" . $catid . "' AND language = '". $langdefault. "'");   //put your condition here                            
$db->setQuery($query);
if ($db->getErrorNum()) {
    echo $db->getErrorMsg();
    exit;
}
$arr = $db->loadObjectList();
$total = count($arr);
$pagination = new JPagination($total, JRequest::getVar('limitstart'), JRequest::getVar('limit'));
$query->where('catid = ' . $catid . ' LIMIT ' . $pagination->limitstart . ', ' . $pagination->limit . '');   //put your condition here
$db->setQuery($query);

$arr = $db->loadObjectList();
if(count($arr)){
foreach ($arr as $obj) {
    $images = json_decode($obj->images);
    ?> 
        <li>
            <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($obj->id,$obj->catid));?>">
               <?php  if (isset($images->image_intro) and !empty($images->image_intro)) : ?>
				<?php $imgfloat =  $images->float_intro; ?>
				
					<img
					<?php if ($images->image_intro_caption):
					echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
		endif; ?>
						src="<?php echo htmlspecialchars($images->image_intro); ?>"
						alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"
						width="235" />
				
				<?php endif; ?>
            </a>
            <div class="info">
                <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($obj->id,$obj->catid));?>" class="title_news"><?php echo $obj->title; ?></a>
                <div class="detail"><?php echo strip_tags($obj->introtext, '<b>,<p>'); ?> </div>
                <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($obj->id,$obj->catid));?>" class="xemchitiet_news"><?php echo JText::_('VIEWDETAILS');?></a>
            </div>
        </li>
<?php }}else{ ?> 
        <li>Đang cập nhật dữ liệu</li>
<?php } ?> 
</ul>
